using System.Threading.Tasks;
using Jinjia.Approve.Entity;
using Jinjia.Approve.Entity.Entity.JJFlow;
using Jinjia.Approve.IRepository.JJFlow;
using Jinjia.Approve.Model.VM.JJFlow.DTO;
using Jinjia.Core.BaseInfrastructure.StorageModel;
using Jinjia.Core.BaseInfrastructure.StorageModel.RepositoryBase;
using Jinjia.Core.UnitOfWork.UnitOfWorkComponent;
using SqlSugar;

namespace Jinjia.Approve.Repository.JJFlow
{
    public class FlowInstanceEmpBakRepository : RepositoryBase<jj_flow_instance_emp_bak>, IFlowInstanceEmpBakRepository
    {
        public FlowInstanceEmpBakRepository(IUnitOfWork unitOfWork, IInitUserInfo initUserInfo) : base(unitOfWork, initUserInfo)
        {
        }

        public async Task<EmpInfo> GetById(int id)
        {
            return await _db.Queryable<jj_flow_instance_emp_bak, erpa_user_tbl>((a, b) => new JoinQueryInfos(JoinType.Left, a.user_id == b.id))
                .Where(a => a.id == id)
                .Select<EmpInfo>("a.id,a.node_id,a.user_id,b.user_name,b.union_id,a.is_complete,a.source_emp_id,a.update_time")
                .FirstAsync();
        }
    }
}